package com.chandra.sample;

/* @(#) DateTest.java
 * Copyright 2013 - 2015 QatarAirways Group. All Rights Reserved.
 *
 * This Software is the proprietary information of QR Group
 * Use is subject to License terms.
 * Created by T4671 on 29/06/2015.
 */

import java.util.Calendar;
import java.util.Date;

public class DateTest {


    public static void main(String args[]){


        displayDateFromValues();
        displayDateParts();
        compareDates();
    }

    public static void displayDateFromValues(){

        Calendar cal2 = Calendar.getInstance();

        cal2.set(Calendar.YEAR, 2015);
        cal2.set(Calendar.MONTH, 06);
        cal2.set(Calendar.DAY_OF_MONTH, 25);
        cal2.set(Calendar.HOUR_OF_DAY, 23);
        cal2.set(Calendar.MINUTE, 59);
        cal2.set(Calendar.SECOND, 59);
        cal2.set(Calendar.MILLISECOND, 59);
        Date toDate = cal2.getTime();
        System.out.println("Date was:-"+toDate);
    }

    public static void displayDateParts(){

        Calendar cal2 = Calendar.getInstance();

        cal2.setTime(new Date());


        System.out.println("YEAR was:-"+cal2.get(Calendar.YEAR));
        System.out.println("MONTH was:-"+cal2.get(Calendar.MONTH));
        System.out.println("DAY_OF_MONTH was:-"+cal2.get(Calendar.DAY_OF_MONTH));
        System.out.println("HOUR was:-"+cal2.get(Calendar.HOUR));
        System.out.println("MINUTE was:-"+cal2.get(Calendar.MINUTE));

    }

    public static void compareDates(){

        Calendar cal1 = Calendar.getInstance();
        cal1.setTimeInMillis(new Date().getTime()-10000);

        Calendar cal2 = Calendar.getInstance();
        cal2.setTime(new Date());


        System.out.println("YEAR was:-"+cal1.compareTo(cal2));


    }
}
